﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="OTA.Notification.Web.Rule.RuleList" Codebehind="RuleList.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>分发适配器规则</title>
    <link href="../../Style/main.css" type="text/css" rel="stylesheet" />

    <script src="../../common/jquery-1.2.6.min.js"></script>

    <script src="../../common/jquery-impromptu.1.5.js"></script>

    <script src="../../common/flexigrid/flexigrid.js"></script>

    <script src="../../common/winbox.js"></script>

    <link rel="stylesheet" href="../../common/flexigrid/flexigrid.css" type="text/css"
        media="screen" />
    <link rel="stylesheet" href="../../style/dfbDialog.css" type="text/css" media="screen" />

    <script type="text/javascript" charset="utf-8">
	
		$(document).ready(function(){
		
		    $('#grid').flexigrid({
		        width: $(document).width() - 10,
		        height: 400,
		        //striped:false,
		        
		        url:'?action=get',
		        
		        dataType: 'json',
		        
		        colModel: [
                    {display: '规则名称', name : 'code', width : 100, sortable : false, align: 'center'},   
                    {display: '消息类型', name : 'flag', width : 180, sortable : false, align: 'left'},   
                    {display: '拥有者', name : 'name', width : 300, sortable : false, align: 'left'},
                    {display: '最后修改人', name : 'user', width : 60, sortable : false, align: 'left'},
                    {display: '最后修改时间', name : 'updatetime', width : 60, sortable : false, align: 'left'} 
                ],
                
                singleSelect: true,
                
                buttons : [
                    { name: '添加', onpress: doCommand},
                    { name: '编辑', onpress: doCommand},
                    { name: '删除', onpress: doCommand},  
                    { separator: true}   
                ],  
                
                showTableToggleBtn: true,
                rp: 15,
                usepager: true,
                useRp: true
                
		    });
		    
		    
		    
		    $('#btnsearch').click(function (){

                var params = $('#txtTitle').val(); 

		        $('#grid').flexOptions({ query: params }).flexReload();

		    });
		    
		});
		
		
		function doCommand(com, grid){
		
            if (com=='编辑'){
            
                if($('.trSelected', grid)[0] == null) return;
            
                var id = $('.trSelected', grid)[0].id.replace(/row/,"");
                
                if(id != '')
                    ShowBox('rule.aspx?id=' + id, 300);
            }
            else if(com == '添加'){
                ShowBox('rule.aspx', 300);
            }
            else{
            
                if($('.trSelected', grid)[0] == null) return;
                
                var id = $('.trSelected', grid)[0].id.replace(/row/,"");
                
                if(id != ''){
                
                    if(confirm("是否确认要删除？")){
                            
                            var data = { key: id };
                            
                            $.post("rulelist.aspx?action=del", data, 
                            
                                function(data, state){
                                    doRefresh();
                                    
                            }, "json");
                    }
                }
            }
        }
        
        function doRefresh(){
            $('#grid').flexOptions().flexReload();
        }
        

        
    </script>

</head>
<body>
    <form id="form1" runat="server">
    </form>
    <div>
        <table>
            <tr>
                <td>
                    规则名称：
                </td>
                <td>
                    <input id="txtTitle" type="text" class="text-area" /><input id="btnsearch" type="button"
                        value="Search" class="button" />
                </td>
            </tr>
        </table>
        <table id="grid">
        </table>
    </div>
</body>
</html>
